home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club (Business) 1997 July / Software of the Month Club - Business (Volume 239) (July 1997).iso / pc / code / f.dxr / 00006_F Scanner Function Scripts.ls < prev    next >
Encoding:
Text File  |  1996-02-19  |  26.5 KB  |  650 lines

  1. global gObjects, gStates, gCursorlist, sQTCharSprite, gLastKeyList, gCurKeyList, sQTSPRITE, gLastCursor, gSoundchannels, gCPU
  2.  
  3. on enterF69
  4.   MakeDynamic(#Scanner, #timesLeverPulled, 0)
  5.   MakeDynamic(#Scanner, #timesScanButtonClicked, 0)
  6.   if getaProp(getaProp(gStates, #BeenThere), #F69) = 0 then
  7.     set fieldNum to the number of cast "PerCentField1.txt"
  8.     repeat with i = 1 to 4
  9.       put " " into field fieldNum
  10.       set fieldNum to fieldNum + 1
  11.     end repeat
  12.   end if
  13. end
  14.  
  15. on doF69VoiceOver
  16.   set scannerObj to getaProp(gObjects, #Scanner)
  17.   set VOPlayList to getaProp(getaProp(gObjects, #Scanner), #VOPlayList)
  18.   set VOTicks to getaProp(getaProp(gObjects, #Scanner), #VOTicks)
  19.   if (count(getaProp(getaProp(gObjects, #Scanner), #subPuzzlesSolved)) = 3) and (getPos(VOPlayList, "F66FG05.aif") = 0) then
  20.     killAnyFernsleyVOPlaying()
  21.     killFAmbientSound()
  22.     playSound("F66FG05.aif", #keyframeFile)
  23.     if not voidp(getaProp(scannerObj, #timer)) then
  24.       DeletetheTimer(getAt(getaProp(scannerObj, #timer), 1))
  25.     end if
  26.     set soundSymbol to value("#" & "F66FG05.aif")
  27.     set soundTicks to getaProp(VOTicks, soundSymbol)
  28.     set soundTimer to Startthetimer(soundTicks + 30, "restartFAmbientSound", #Scanner)
  29.     addUnique(VOPlayList, "F66FG05.aif")
  30.     MakeDynamic(#Scanner, #VOPlayList, VOPlayList)
  31.   else
  32.     if (getaProp(getaProp(gStates, #BeenThere), #F69) = 1) and (getaProp(getaProp(gObjects, #Scanner), #timesScanButtonClicked) >= 7) and (count(getaProp(getaProp(gObjects, #Scanner), #subPuzzlesSolved)) = 0) then
  33.       killAnyFernsleyVOPlaying()
  34.       killFAmbientSound()
  35.       playSound("F66FW02.aif", #keyframeFile)
  36.       if not voidp(getaProp(scannerObj, #timer)) then
  37.         DeletetheTimer(getAt(getaProp(scannerObj, #timer), 1))
  38.       end if
  39.       set soundSymbol to value("#" & "F66FW02.aif")
  40.       set soundTicks to getaProp(VOTicks, soundSymbol)
  41.       set soundTimer to Startthetimer(soundTicks + 30, "restartFAmbientSound", #Scanner)
  42.     else
  43.       if (getaProp(getaProp(gStates, #BeenThere), #F69) = 1) and (getaProp(getaProp(gObjects, #Scanner), #timesScanButtonClicked) = 6) and (count(getaProp(getaProp(gObjects, #Scanner), #subPuzzlesSolved)) = 0) then
  44.         killAnyFernsleyVOPlaying()
  45.         killFAmbientSound()
  46.         playSound("F66FW03.aif", #keyframeFile)
  47.         if not voidp(getaProp(scannerObj, #timer)) then
  48.           DeletetheTimer(getAt(getaProp(scannerObj, #timer), 1))
  49.         end if
  50.         set soundSymbol to value("#" & "F66FW03.aif")
  51.         set soundTicks to getaProp(VOTicks, soundSymbol)
  52.         set soundTimer to Startthetimer(soundTicks + 30, "restartFAmbientSound", #Scanner)
  53.       else
  54.         if (getaProp(getaProp(gStates, #BeenThere), #F69) = 1) and (getaProp(getaProp(gObjects, #Scanner), #timesScanButtonClicked) = 5) and (count(getaProp(getaProp(gObjects, #Scanner), #subPuzzlesSolved)) = 0) then
  55.           killAnyFernsleyVOPlaying()
  56.           killFAmbientSound()
  57.           playSound("F66FW01.aif", #keyframeFile)
  58.           if not voidp(getaProp(scannerObj, #timer)) then
  59.             DeletetheTimer(getAt(getaProp(scannerObj, #timer), 1))
  60.           end if
  61.           set soundSymbol to value("#" & "F66FW01.aif")
  62.           set soundTicks to getaProp(VOTicks, soundSymbol)
  63.           set soundTimer to Startthetimer(soundTicks + 30, "restartFAmbientSound", #Scanner)
  64.         else
  65.           if (getaProp(getaProp(gStates, #BeenThere), #F69) = 1) and (getaProp(getaProp(gObjects, #Scanner), #timesScanButtonClicked) = 4) and (count(getaProp(getaProp(gObjects, #Scanner), #subPuzzlesSolved)) = 0) then
  66.             killAnyFernsleyVOPlaying()
  67.             killFAmbientSound()
  68.             playSound("F66FW01.aif", #keyframeFile)
  69.             if not voidp(getaProp(scannerObj, #timer)) then
  70.               DeletetheTimer(getAt(getaProp(scannerObj, #timer), 1))
  71.             end if
  72.             set soundSymbol to value("#" & "F66FW01.aif")
  73.             set soundTicks to getaProp(VOTicks, soundSymbol)
  74.             set soundTimer to Startthetimer(soundTicks + 30, "restartFAmbientSound", #Scanner)
  75.           end if
  76.         end if
  77.       end if
  78.     end if
  79.   end if
  80. end
  81.  
  82. on killFAmbientSound
  83.   if not voidp(getaProp(gSoundchannels, 2)) then
  84.     stopsound(getaProp(getaProp(gSoundchannels, 2), #name))
  85.   end if
  86. end
  87.  
  88. on restartFAmbientSound
  89.   playSound("Fambt1.aif", #AmbientLoop)
  90. end
  91.  
  92. on timeSound inName
  93.   set longName to "CHAOS:DATA:F_Enviro:F_Sfx:" & inName
  94.   set startTime to the ticks
  95.   sound playFile 1, longName
  96.   repeat while soundBusy(1)
  97.     nothing()
  98.   end repeat
  99.   set endTime to the ticks
  100.   set soundTime to endTime - startTime
  101. end
  102.  
  103. on killAnyFernsleyVOPlaying
  104.   if not voidp(gSoundchannels) then
  105.     if count(gSoundchannels) > 0 then
  106.       repeat with i = 1 to count(gSoundchannels)
  107.         set channelNum to getPropAt(gSoundchannels, i)
  108.         set channelInfo to getaProp(gSoundchannels, channelNum)
  109.         set soundName to getaProp(channelInfo, #name)
  110.         if soundName contains "F66F" then
  111.           stopsound(soundName)
  112.         end if
  113.       end repeat
  114.     end if
  115.   end if
  116. end
  117.  
  118. on releasePapers
  119.   if count(getaProp(getaProp(gObjects, #scanpapers), #paperLocRects)) = 16 then
  120.     shufflePapers()
  121.     repeat with i = 1 to 16
  122.       set paperRef to value("#Paper" & string(i))
  123.       set OBj to getaProp(gObjects, paperRef)
  124.       set the loc of sprite getaProp(OBj, #SpriteNum) to getaProp(OBj, #loc)
  125.       set hotrectnum to integer(getaProp(OBj, #SpriteNum) & "01")
  126.       setaProp(getaProp(gHotRects, hotrectnum), #rect, getAt(getaProp(OBj, #Hotrect), 1))
  127.       updateStage()
  128.     end repeat
  129.   end if
  130. end
  131.  
  132. on shufflePapers
  133.   set paperLocRectList to getaProp(getaProp(gObjects, #scanpapers), #paperLocRects)
  134.   repeat with i = 1 to 16
  135.     set paperRef to value("#Paper" & string(i))
  136.     set the randomSeed to the ticks
  137.     set ranIndex to random(count(paperLocRectList))
  138.     if ranIndex = 0 then
  139.       set ranIndex to 1
  140.     end if
  141.     set thisProp to getPropAt(paperLocRectList, ranIndex)
  142.     set thisElement to getaProp(paperLocRectList, thisProp)
  143.     MakeDynamic(paperRef, #loc, getAt(thisElement, 1))
  144.     MakeDynamic(paperRef, #Hotrect, getAt(thisElement, 2))
  145.     deleteProp(paperLocRectList, thisProp)
  146.   end repeat
  147.   MakeDynamic(#scanpapers, #paperLocRects, [:])
  148. end
  149.  
  150. on DoScanLever
  151.   set scannerObj to getaProp(gObjects, #Scanner)
  152.   set VOPlayList to getaProp(getaProp(gObjects, #Scanner), #VOPlayList)
  153.   set VOTicks to getaProp(getaProp(gObjects, #Scanner), #VOTicks)
  154.   if count(getaProp(getaProp(gObjects, #Scanner), #subPuzzlesSolved)) = 4 then
  155.     if (value(field "PerCentField1.txt") = 9) and (value(field "PerCentField2.txt") = 42) and (value(field "PerCentField3.txt") = 22) and (value(field "PerCentField4.txt") = 27) and (getaProp(getaProp(gObjects, #Scanner), #solved) = #false) then
  156.       MakeDynamic(#Scanner, #solved, #true)
  157.       setaProp(getaProp(gStates, #Conditions), #Forest, #true)
  158.       playSound("F69lever.aif", #keyframeCast, 1)
  159.       Startthetimer(10, "growTrees")
  160.     else
  161.       playSound("F69fail.aif", #keyframeCast, 1)
  162.       killAnyFernsleyVOPlaying()
  163.       killFAmbientSound()
  164.       playSound("F66FG06.aif", #keyframeFile)
  165.       if not voidp(getaProp(scannerObj, #timer)) then
  166.         DeletetheTimer(getAt(getaProp(scannerObj, #timer), 1))
  167.       end if
  168.       set soundSymbol to value("#" & "F66FG06.aif")
  169.       set soundTicks to getaProp(VOTicks, soundSymbol)
  170.       set soundTimer to Startthetimer(soundTicks + 30, "restartFAmbientSound", #Scanner)
  171.     end if
  172.   else
  173.     playSound("F69fail.aif", #keyframeCast)
  174.   end if
  175.   set timesLeverPulled to getaProp(getaProp(gObjects, #Scanner), #timesLeverPulled)
  176.   set timesLeverPulled to timesLeverPulled + 1
  177.   MakeDynamic(#Scanner, #timesLeverPulled, timesLeverPulled)
  178.   if (getaProp(getaProp(gObjects, #Scanner), #timesLeverPulled) = 3) and (getaProp(getaProp(gObjects, #Scanner), #solved) = #false) then
  179.     PDARelease("J04m26p.mov")
  180.   end if
  181. end
  182.  
  183. on DoScanLever2
  184.   if getaProp(getaProp(gObjects, #Scanner), #solved) = #true then
  185.     playSound("F69lever.aif", #keyframeCast)
  186.     Startthetimer(10, "growTrees")
  187.   end if
  188. end
  189.  
  190. on growTrees
  191.   set LastKeyRef to #F69G
  192.   set NextKeyRef to setKFGlobals(#F68B)
  193.   DoTransition(LastKeyRef, NextKeyRef)
  194.   set gLastCursor to getaProp(gCursorlist, #NullCursor)
  195.   set the rect of sprite sQTSPRITE to rect(0, 0, 560, 336)
  196.   go("TransQT")
  197.   delScreenState()
  198. end
  199.  
  200. on DoScanPaper OBJref
  201.   set OBj to getaProp(gObjects, OBJref)
  202.   set scannerObj to getaProp(gObjects, #Scanner)
  203.   set scanSurface to getaProp(getaProp(gObjects, #Scanner), #scanSurfaceRect)
  204.   set paperIndex to getPos(getaProp(getaProp(gObjects, #Scanner), #papersOnScanner), OBJref)
  205.   if (getaProp(OBj, #DisplayState) = #INIT) and inside(getaProp(OBj, #loc), scanSurface) then
  206.     if voidp(getaProp(getaProp(scannerObj, #papersOnScanner), OBJref)) then
  207.       setaProp(getaProp(scannerObj, #papersOnScanner), OBJref, getaProp(OBj, #SpriteNum))
  208.       MakeDynamic(#Scanner, #papersOnScanner, getaProp(scannerObj, #papersOnScanner))
  209.     end if
  210.   end if
  211.   if (getaProp(OBj, #DisplayState) = #INIT) and ((count(getaProp(scannerObj, #papersOnScanner)) > 4) or not inside(getaProp(OBj, #loc), scanSurface)) then
  212.     if not voidp(getaProp(getaProp(scannerObj, #papersOnScanner), OBJref)) then
  213.       deleteProp(getaProp(scannerObj, #papersOnScanner), OBJref)
  214.       MakeDynamic(#Scanner, #papersOnScanner, getaProp(scannerObj, #papersOnScanner))
  215.     end if
  216.     returnToOrigPos(OBJref)
  217.   end if
  218. end
  219.  
  220. on returnToOrigPos OBJref
  221.   set OBj to getaProp(gObjects, OBJref)
  222.   set the loc of sprite getaProp(OBj, #SpriteNum) to getaProp(OBj, #OriginalLOC)
  223.   MakeDynamic(OBJref, #loc, the loc of sprite getaProp(OBj, #SpriteNum))
  224.   MakeDynamic(OBJref, #Hotrect, value(string(getaProp(OBj, #OriginalHotrect))))
  225.   set hotrectnum to integer(getaProp(OBj, #SpriteNum) & "01")
  226.   setaProp(getaProp(gHotRects, hotrectnum), #rect, getAt(getaProp(OBj, #Hotrect), 1))
  227. end
  228.  
  229. on DoClearButton
  230.   set papersOnScanner to getaProp(getaProp(gObjects, #Scanner), #papersOnScanner)
  231.   repeat with i = 1 to count(papersOnScanner)
  232.     set the castNum of sprite getAt(papersOnScanner, i) to the number of cast getaProp(getaProp(getaProp(gObjects, getPropAt(papersOnScanner, i)), #cast), #INIT)
  233.     MakeDynamic(getPropAt(papersOnScanner, i), #DisplayState, #INIT)
  234.     set the ink of sprite getAt(papersOnScanner, i) to 0
  235.     MakeDynamic(getPropAt(papersOnScanner, i), #SpriteProp, [#ink: 0])
  236.     returnToOrigPos(getPropAt(papersOnScanner, i))
  237.   end repeat
  238.   MakeDynamic(#Scanner, #papersOnScanner, [:])
  239. end
  240.  
  241. on DoScanButton
  242.   set OBJref to #scanBeam
  243.   set OBj to getaProp(gObjects, #scanBeam)
  244.   set beamSprite to getaProp(OBj, #SpriteNum)
  245.   set flag to #createPolygons
  246.   set papersOnScanner to getaProp(getaProp(gObjects, #Scanner), #papersOnScanner)
  247.   set timesScanButtonClicked to getaProp(getaProp(gObjects, #Scanner), #timesScanButtonClicked)
  248.   set timesScanButtonClicked to timesScanButtonClicked + 1
  249.   MakeDynamic(#Scanner, #timesScanButtonClicked, timesScanButtonClicked)
  250.   set polygonCount to 0
  251.   repeat with i = 1 to count(papersOnScanner)
  252.     if getaProp(getaProp(gObjects, getPropAt(papersOnScanner, i)), #DisplayState) = #polygon then
  253.       set polygonCount to polygonCount + 1
  254.     end if
  255.   end repeat
  256.   if polygonCount = 4 then
  257.     set flag to checkSubPuzzleSolution()
  258.   end if
  259.   playSound("F69scan.aif", #keyframeCast)
  260.   set the loc of sprite beamSprite to getaProp(OBj, #startloc)
  261.   updateStage()
  262.   if gCPU = #mpc then
  263.     set myTimer to the ticks
  264.     repeat while the ticks < (myTimer + 15)
  265.       CursorandUpdate()
  266.     end repeat
  267.   end if
  268.   repeat while the locV of sprite beamSprite > getAt(getaProp(OBj, #EndLoc), 2)
  269.     set the loc of sprite beamSprite to the loc of sprite beamSprite - point(0, 4)
  270.     set scanRect to rect(the left of sprite beamSprite, the bottom of sprite beamSprite, the right of sprite beamSprite, the bottom of sprite beamSprite + 5)
  271.     if flag = #createPolygons then
  272.       createPolygons(beamSprite, papersOnScanner, scanRect)
  273.     else
  274.       if flag <> #noSolution then
  275.         sendPolygonsNorth(flag, beamSprite, papersOnScanner, scanRect)
  276.       end if
  277.     end if
  278.     CursorandUpdate()
  279.   end repeat
  280.   if (flag <> #noSolution) and (flag <> #createPolygons) then
  281.     createSubPuzzleIcon(flag, papersOnScanner)
  282.     set subPuzzlesSolved to getaProp(getaProp(gObjects, #Scanner), #subPuzzlesSolved)
  283.     add(subPuzzlesSolved, flag)
  284.     MakeDynamic(#Scanner, #subPuzzlesSolved, subPuzzlesSolved)
  285.     MakeDynamic(#Scanner, #papersOnScanner, [:])
  286.     setTextField(flag)
  287.   end if
  288.   set the loc of sprite beamSprite to point(-2000, -2000)
  289.   updateStage()
  290.   stopsound("F69scan.aif")
  291.   doF69VoiceOver()
  292. end
  293.  
  294. on createPolygons inBeamSprite, InPapersList, inScanRect
  295.   repeat with i = 1 to count(InPapersList)
  296.     set paperRef to getPropAt(InPapersList, i)
  297.     set SpriteNum to getAt(InPapersList, i)
  298.     set paperObj to getaProp(gObjects, paperRef)
  299.     set thisConstrainRect to getaProp(paperObj, #constrainRect)
  300.     if getaProp(getaProp(gObjects, getPropAt(InPapersList, i)), #DisplayState) <> #polygon then
  301.       if intersect(inScanRect, the rect of sprite SpriteNum) > rect(0, 0, 0, 0) then
  302.         MakeDynamic(paperRef, #DisplayState, #polygon)
  303.         set the castNum of sprite SpriteNum to the number of cast getaProp(getaProp(getaProp(gObjects, paperRef), #cast), #polygon)
  304.         if not inside(the loc of sprite SpriteNum, thisConstrainRect) then
  305.           if the locH of sprite SpriteNum < getAt(thisConstrainRect, 1) then
  306.             set the locH of sprite SpriteNum to getAt(thisConstrainRect, 1)
  307.           end if
  308.           if the locH of sprite SpriteNum > getAt(thisConstrainRect, 3) then
  309.             set the locH of sprite SpriteNum to getAt(thisConstrainRect, 3)
  310.           end if
  311.           if the locV of sprite SpriteNum < getAt(thisConstrainRect, 2) then
  312.             set the locV of sprite SpriteNum to getAt(thisConstrainRect, 2)
  313.           end if
  314.           if the locV of sprite SpriteNum > getAt(thisConstrainRect, 4) then
  315.             set the locV of sprite SpriteNum to getAt(thisConstrainRect, 4)
  316.           end if
  317.         end if
  318.         MakeDynamic(paperRef, #loc, the loc of sprite SpriteNum)
  319.         set the ink of sprite getAt(InPapersList, i) to 33
  320.         MakeDynamic(paperRef, #SpriteProp, [#ink: 33])
  321.         updateStage()
  322.         set hotrectnum to integer(getaProp(paperObj, #SpriteNum) & "01")
  323.         MakeDynamic(paperRef, #Hotrect, [the rect of sprite SpriteNum])
  324.         setaProp(getaProp(gHotRects, hotrectnum), #rect, getAt(getaProp(paperObj, #Hotrect), 1))
  325.       end if
  326.     end if
  327.   end repeat
  328. end
  329.  
  330. on sendPolygonsNorth OBJref, inBeamSprite, InPapersList, inScanRect
  331.   repeat with i = 1 to count(InPapersList)
  332.     if intersect(inScanRect, the rect of sprite getAt(InPapersList, i)) > rect(0, 0, 0, 0) then
  333.       set the constraint of sprite getAt(InPapersList, i) to 0
  334.       set the loc of sprite getAt(InPapersList, i) to point(-2000, -2000)
  335.       MakeDynamic(getPropAt(InPapersList, i), #loc, point(-2000, -2000))
  336.       updateStage()
  337.       set paperRef to getPropAt(InPapersList, i)
  338.       set paperObj to getaProp(gObjects, paperRef)
  339.       set hotrectnum to integer(getaProp(paperObj, #SpriteNum) & "01")
  340.       MakeDynamic(paperRef, #Hotrect, [the rect of sprite getaProp(paperObj, #SpriteNum)])
  341.       setaProp(getaProp(gHotRects, hotrectnum), #rect, getAt(getaProp(paperObj, #Hotrect), 1))
  342.     end if
  343.   end repeat
  344. end
  345.  
  346. on createSubPuzzleIcon OBJref, InPapersList
  347.   set spritesSentNorth to 0
  348.   repeat with j = 1 to count(InPapersList)
  349.     if the loc of sprite getAt(InPapersList, j) = point(-2000, -2000) then
  350.       set spritesSentNorth to spritesSentNorth + 1
  351.     end if
  352.   end repeat
  353.   if spritesSentNorth = 4 then
  354.     set the loc of sprite getaProp(getaProp(gObjects, OBJref), #SpriteNum) to getaProp(getaProp(gObjects, OBJref), #loc2)
  355.     MakeDynamic(OBJref, #loc, getaProp(getaProp(gObjects, OBJref), #loc2))
  356.   end if
  357. end
  358.  
  359. on checkSubPuzzleSolution
  360.   set OBj to getaProp(gObjects, #Scanner)
  361.   set solutionsObj to getaProp(getaProp(gObjects, #Scanner), #SubPuzzleSolutions)
  362.   set papersOnScannerPropList to getaProp(getaProp(gObjects, #Scanner), #papersOnScanner)
  363.   set papersOnScannerLinearList to []
  364.   repeat with i = 1 to count(papersOnScannerPropList)
  365.     add(papersOnScannerLinearList, getPropAt(papersOnScannerPropList, i))
  366.   end repeat
  367.   sort(papersOnScannerLinearList)
  368.   repeat with i = 1 to count(solutionsObj)
  369.     set thisSubPuzzleRef to getPropAt(solutionsObj, i)
  370.     set thisSolutionList to getaProp(solutionsObj, thisSubPuzzleRef)
  371.     sort(thisSolutionList)
  372.     if thisSolutionList = papersOnScannerLinearList then
  373.       if checkPolygonAligment() then
  374.         return thisSubPuzzleRef
  375.       end if
  376.     end if
  377.   end repeat
  378.   return #noSolution
  379. end
  380.  
  381. on checkPolygonAligment
  382.   set alignCount to 0
  383.   set papersOnScannerPropList to getaProp(getaProp(gObjects, #Scanner), #papersOnScanner)
  384.   set rectHalfSize to 15
  385.   set locHTotal to 0
  386.   set locVTotal to 0
  387.   repeat with i = 1 to count(papersOnScannerPropList)
  388.     set locHTotal to locHTotal + the locH of sprite getAt(papersOnScannerPropList, 1)
  389.     set locVTotal to locVTotal + the locV of sprite getAt(papersOnScannerPropList, 1)
  390.   end repeat
  391.   set locHAverage to integer(locHTotal / count(papersOnScannerPropList))
  392.   set locVAverage to integer(locVTotal / count(papersOnScannerPropList))
  393.   set alignmentRect to rect(locHAverage - rectHalfSize, locVAverage - rectHalfSize, locHAverage + rectHalfSize, locVAverage + rectHalfSize)
  394.   repeat with i = 1 to count(papersOnScannerPropList)
  395.     if inside(the loc of sprite getAt(papersOnScannerPropList, i), alignmentRect) then
  396.       set alignCount to alignCount + 1
  397.     end if
  398.   end repeat
  399.   if alignCount = 4 then
  400.     return 1
  401.   else
  402.     return 0
  403.   end if
  404. end
  405.  
  406. on setTextField OBJref
  407.   if OBJref = #SubPuzzle1 then
  408.     put "00" into field "PerCentField1.txt"
  409.   else
  410.     if OBJref = #SubPuzzle2 then
  411.       put "00" into field "PerCentField2.txt"
  412.     else
  413.       if OBJref = #SubPuzzle3 then
  414.         put "00" into field "PerCentField3.txt"
  415.       else
  416.         if OBJref = #SubPuzzle4 then
  417.           put "00" into field "PerCentField4.txt"
  418.         end if
  419.       end if
  420.     end if
  421.   end if
  422. end
  423.  
  424. on DoTenPerCent OBJref
  425.   set subPuzzlesSolved to getaProp(getaProp(gObjects, #Scanner), #subPuzzlesSolved)
  426.   if (OBJref = #PerCent10HotRect1) and (getPos(subPuzzlesSolved, #SubPuzzle1) > 0) then
  427.     set firstDigit to value(char 1 of field "PerCentField1.txt")
  428.     if firstDigit < 9 then
  429.       set firstDigit to firstDigit + 1
  430.     else
  431.       set firstDigit to 0
  432.     end if
  433.     playSound("F69num.aif", #keyframeCast)
  434.     put string(firstDigit) into char 1 of field "PerCentField1.txt"
  435.   else
  436.     if (OBJref = #PerCent10HotRect2) and (getPos(subPuzzlesSolved, #SubPuzzle2) > 0) then
  437.       set firstDigit to value(char 1 of field "PerCentField2.txt")
  438.       if firstDigit < 9 then
  439.         set firstDigit to firstDigit + 1
  440.       else
  441.         set firstDigit to 0
  442.       end if
  443.       playSound("F69num.aif", #keyframeCast)
  444.       put string(firstDigit) into char 1 of field "PerCentField2.txt"
  445.     else
  446.       if (OBJref = #PerCent10HotRect3) and (getPos(subPuzzlesSolved, #SubPuzzle3) > 0) then
  447.         set firstDigit to value(char 1 of field "PerCentField3.txt")
  448.         if firstDigit < 9 then
  449.           set firstDigit to firstDigit + 1
  450.         else
  451.           set firstDigit to 0
  452.         end if
  453.         playSound("F69num.aif", #keyframeCast)
  454.         put string(firstDigit) into char 1 of field "PerCentField3.txt"
  455.       else
  456.         if (OBJref = #PerCent10HotRect4) and (getPos(subPuzzlesSolved, #SubPuzzle4) > 0) then
  457.           set firstDigit to value(char 1 of field "PerCentField4.txt")
  458.           if firstDigit < 9 then
  459.             set firstDigit to firstDigit + 1
  460.           else
  461.             set firstDigit to 0
  462.           end if
  463.           playSound("F69num.aif", #keyframeCast)
  464.           put string(firstDigit) into char 1 of field "PerCentField4.txt"
  465.         end if
  466.       end if
  467.     end if
  468.   end if
  469. end
  470.  
  471. on DoOnePerCent OBJref
  472.   set subPuzzlesSolved to getaProp(getaProp(gObjects, #Scanner), #subPuzzlesSolved)
  473.   if (OBJref = #PerCent01HotRect1) and (getPos(subPuzzlesSolved, #SubPuzzle1) > 0) then
  474.     set secondDigit to value(char 2 of field "PerCentField1.txt")
  475.     if secondDigit < 9 then
  476.       set secondDigit to secondDigit + 1
  477.     else
  478.       set secondDigit to 0
  479.     end if
  480.     playSound("F69num.aif", #keyframeCast)
  481.     put string(secondDigit) into char 2 of field "PerCentField1.txt"
  482.   else
  483.     if (OBJref = #PerCent01HotRect2) and (getPos(subPuzzlesSolved, #SubPuzzle2) > 0) then
  484.       set secondDigit to value(char 2 of field "PerCentField2.txt")
  485.       if secondDigit < 9 then
  486.         set secondDigit to secondDigit + 1
  487.       else
  488.         set secondDigit to 0
  489.       end if
  490.       playSound("F69num.aif", #keyframeCast)
  491.       put string(secondDigit) into char 2 of field "PerCentField2.txt"
  492.     else
  493.       if (OBJref = #PerCent01HotRect3) and (getPos(subPuzzlesSolved, #SubPuzzle3) > 0) then
  494.         set secondDigit to value(char 2 of field "PerCentField3.txt")
  495.         if secondDigit < 9 then
  496.           set secondDigit to secondDigit + 1
  497.         else
  498.           set secondDigit to 0
  499.         end if
  500.         playSound("F69num.aif", #keyframeCast)
  501.         put string(secondDigit) into char 2 of field "PerCentField3.txt"
  502.       else
  503.         if (OBJref = #PerCent01HotRect4) and (getPos(subPuzzlesSolved, #SubPuzzle4) > 0) then
  504.           set secondDigit to value(char 2 of field "PerCentField4.txt")
  505.           if secondDigit < 9 then
  506.             set secondDigit to secondDigit + 1
  507.           else
  508.             set secondDigit to 0
  509.           end if
  510.           playSound("F69num.aif", #keyframeCast)
  511.           put string(secondDigit) into char 2 of field "PerCentField4.txt"
  512.         end if
  513.       end if
  514.     end if
  515.   end if
  516. end
  517.  
  518. on GrabDragScanPapers OBJref
  519.   set OBj to getaProp(gObjects, OBJref)
  520.   cursor(getaProp(gCursorlist, #Grab))
  521.   if not voidp(getaProp(getaProp(OBj, #sound), #down)) then
  522.     playSound(getaProp(getaProp(OBj, #sound), #down), #keyframeCast)
  523.   end if
  524.   if getaProp(OBj, #DisplayState) = #INIT then
  525.     set H to the mouseH
  526.     set V to the mouseV
  527.     set OffsetH to H - the locH of sprite getaProp(OBj, #SpriteNum)
  528.     set OffsetV to V - the locV of sprite getaProp(OBj, #SpriteNum)
  529.     repeat while the mouseDown
  530.       set H to the mouseH
  531.       set V to the mouseV
  532.       set the locV of sprite getaProp(OBj, #SpriteNum) to V - OffsetV
  533.       set the locH of sprite getaProp(OBj, #SpriteNum) to H - OffsetH
  534.       CursorandUpdate()
  535.     end repeat
  536.   else
  537.     if getaProp(OBj, #DisplayState) = #polygon then
  538.       set thisConstrainRect to getaProp(OBj, #constrainRect)
  539.       set H to the mouseH
  540.       set V to the mouseV
  541.       set poffsetH to H - the locH of sprite getaProp(OBj, #SpriteNum)
  542.       set poffsetV to V - the locV of sprite getaProp(OBj, #SpriteNum)
  543.       repeat while the mouseDown
  544.         set H to the mouseH
  545.         set V to the mouseV
  546.         set the locV of sprite getaProp(OBj, #SpriteNum) to V - poffsetV
  547.         set the locH of sprite getaProp(OBj, #SpriteNum) to H - poffsetH
  548.         if not inside(the loc of sprite getaProp(OBj, #SpriteNum), thisConstrainRect) then
  549.           if the locH of sprite getaProp(OBj, #SpriteNum) < getAt(thisConstrainRect, 1) then
  550.             set the locH of sprite getaProp(OBj, #SpriteNum) to getAt(thisConstrainRect, 1)
  551.           end if
  552.           if the locH of sprite getaProp(OBj, #SpriteNum) > getAt(thisConstrainRect, 3) then
  553.             set the locH of sprite getaProp(OBj, #SpriteNum) to getAt(thisConstrainRect, 3)
  554.           end if
  555.           if the locV of sprite getaProp(OBj, #SpriteNum) < getAt(thisConstrainRect, 2) then
  556.             set the locV of sprite getaProp(OBj, #SpriteNum) to getAt(thisConstrainRect, 2)
  557.           end if
  558.           if the locV of sprite getaProp(OBj, #SpriteNum) > getAt(thisConstrainRect, 4) then
  559.             set the locV of sprite getaProp(OBj, #SpriteNum) to getAt(thisConstrainRect, 4)
  560.           end if
  561.         end if
  562.         CursorandUpdate()
  563.       end repeat
  564.     end if
  565.   end if
  566.   if not voidp(getaProp(getaProp(OBj, #sound), #UP)) then
  567.     playSound(getaProp(getaProp(OBj, #sound), #UP), #keyframeCast)
  568.   end if
  569.   cursor(getaProp(gCursorlist, #Hand))
  570.   updateStage()
  571.   DynamicLOCRECT2(OBJref)
  572.   do(getaProp(getaProp(OBj, #Action), #UP))
  573.   CursorandUpdate()
  574. end
  575.  
  576. on DynamicLOCRECT2 OBJref
  577.   set OBj to getaProp(gObjects, OBJref)
  578.   if not voidp(getaProp(OBj, #Hotrect)) then
  579.     if voidp(getaProp(OBj, #OriginalHotrect)) then
  580.       MakeDynamic(OBJref, #OriginalHotrect, value(string(getaProp(OBj, #Hotrect))))
  581.     end if
  582.     MakeDynamic(OBJref, #Hotrect, [the rect of sprite getaProp(OBj, #SpriteNum)])
  583.     set hotrectnum to integer(getaProp(OBj, #SpriteNum) & "01")
  584.     setaProp(getaProp(gHotRects, hotrectnum), #rect, getAt(getaProp(OBj, #Hotrect), 1))
  585.   else
  586.     if not voidp(getaProp(OBj, #SpriteProp)) then
  587.       if not voidp(getaProp(getaProp(OBj, #SpriteProp), #rect)) then
  588.         if voidp(getaProp(OBj, #Originalrect)) then
  589.           setaProp(OBj, #Originalrect, value(string(getaProp(getaProp(OBj, #SpriteProp), #rect))))
  590.         end if
  591.         setaProp(getaProp(OBj, #SpriteProp), #rect, the rect of sprite getaProp(OBj, #SpriteNum))
  592.       end if
  593.     end if
  594.   end if
  595.   if not voidp(getaProp(OBj, #loc)) then
  596.     if voidp(getaProp(OBj, #OriginalLOC)) then
  597.       MakeDynamic(OBJref, #OriginalLOC, value(string(getaProp(OBj, #loc))))
  598.     end if
  599.     MakeDynamic(OBJref, #loc, the loc of sprite getaProp(OBj, #SpriteNum))
  600.   end if
  601. end
  602.  
  603. on toggleScanner
  604.   if getaProp(getaProp(gObjects, #Scanner), #solved) = #true then
  605.     setaProp(getaProp(gObjects, #Scanner), #solved, #false)
  606.   else
  607.     setaProp(getaProp(gObjects, #Scanner), #solved, #true)
  608.   end if
  609.   put "scannerSolved" && getaProp(getaProp(gObjects, #Scanner), #solved)
  610. end
  611.  
  612. on toggleScanpapers
  613.   if getaProp(getaProp(gObjects, #scanpapers), #solved) = #true then
  614.     setaProp(getaProp(gObjects, #scanpapers), #solved, #false)
  615.   else
  616.     setaProp(getaProp(gObjects, #scanpapers), #solved, #true)
  617.   end if
  618.   put "scanpapersSolved" && getaProp(getaProp(gObjects, #scanpapers), #solved)
  619. end
  620.  
  621. on findAllPapers
  622.   AddObjects([#BagObj])
  623.   setaProp(getaProp(gObjects, #BagObj), #Aquired, #true)
  624.   set Papers to getaProp(gObjects, #scanpapers)
  625.   repeat with i = 1 to 16
  626.     set OBJref to value("#" & "Paper" & i)
  627.     add(getaProp(Papers, #Children), OBJref)
  628.   end repeat
  629.   MakeDynamic(#scanpapers, #State, #on)
  630.   Jumptokey(#F69)
  631. end
  632.  
  633. on pickUpPapers
  634.   if getaProp(getaProp(gObjects, #BagObj), #Aquired) = #false then
  635.     setaProp(getaProp(gObjects, #BagObj), #Aquired, #true)
  636.   end if
  637.   set Papers to getaProp(gObjects, #scanpapers)
  638.   set papersFound to getaProp(Papers, #Children)
  639.   repeat with i = 1 to 16
  640.     set OBJref to value("#" & "Paper" & i)
  641.     addUnique(papersFound, OBJref)
  642.     set FindObjRef to value("#" & "FindPaper" & i)
  643.     MakeDynamic(FindObjRef, #Hotrect, [rect(0, 0, 0, 0)])
  644.     MakeDynamic(FindObjRef, #DisplayState, #false)
  645.   end repeat
  646.   MakeDynamic(#scanpapers, #State, #on)
  647.   MakeDynamic(#scanpapers, #solved, #true)
  648.   MakeDynamic(#scanpapers, #Children, papersFound)
  649. end
  650.